Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect wallet with ledger live app #36

Merged
merged 18 commits into from
Nov 28, 2023
Merged

Connect wallet with ledger live app #36

merged 18 commits into from
Nov 28, 2023

Conversation

kkosiorowska
Copy link
Contributor

This PR adds the possibility to request access to a user’s account in the ledger live app. To do this, we need to extend the permissions in the manifest file - account.request. When the user has selected an account, let's save it in a special context for global access.

What has been done

  • Create an environment variable to switch the test network to the regular one - VITE_USE_TESTNET
  • Create a context for an account to have global access to it.
  • Change the style for a button - Styles are still not perfect but let's correct that in a separate task.
  • Update global styles
  • Add functions to format the token amount

UI

Screenshot 2023-11-17 at 13 04 06

To connect accounts with the dApp let's use the `useRequestAccount` hook from the WALLET API for this.  Also, we should store the account data in context to have global access to it.
We should correctly display user balances. Let us use the formatting functions and display the balance correctly by region.
- Ad comment about tooltip
- Add different style when an account is not defined
@kkosiorowska kkosiorowska self-assigned this Nov 20, 2023
@kkosiorowska kkosiorowska mentioned this pull request Nov 23, 2023
Copy link
Contributor

@r-czajkowski r-czajkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass, left some comments. Overall looks good.

Just wonder how we can be more abstract in terms of requesting a user to connect to an account 🤔. Would be great if we could easily switch from Ledger Live to a standalone dapp. But this is probably something that should be solved in another PR.

dapp/src/utils/numbers.ts Outdated Show resolved Hide resolved
dapp/src/theme/utils/colors.ts Show resolved Hide resolved
dapp/src/components/Navbar/ConnectWallet.tsx Outdated Show resolved Hide resolved
dapp/src/constants/chains.ts Outdated Show resolved Hide resolved
dapp/.env Outdated Show resolved Hide resolved
@nkuba nkuba added this to the MVP milestone Nov 27, 2023
@kkosiorowska
Copy link
Contributor Author

First pass, left some comments. Overall looks good.

Just wonder how we can be more abstract in terms of requesting a user to connect to an account 🤔. Would be great if we could easily switch from Ledger Live to a standalone dapp. But this is probably something that should be solved in another PR.

Currently, we don't distinguish the Ledger Live app and the standalone dapp. However, in the future, I see it as something like this: one hook or service returning to us a set of the right tools depending on which application it is. At the moment I have created custom hooks for the ledger live app but I think adapting this for the standalone app should be done with another PR.

dapp/src/contexts/LedgerLiveAppContext.tsx Outdated Show resolved Hide resolved
dapp/src/contexts/LedgerLiveAppContext.tsx Outdated Show resolved Hide resolved
dapp/src/DApp.tsx Outdated Show resolved Hide resolved
dapp/src/contexts/LedgerLiveAppContext.tsx Outdated Show resolved Hide resolved
dapp/src/theme/index.ts Outdated Show resolved Hide resolved
dapp/src/components/Navbar/ConnectWallet.tsx Outdated Show resolved Hide resolved
dapp/src/components/Navbar/ConnectWallet.tsx Outdated Show resolved Hide resolved
- Remove a dir for providers and move it to contexts dir.
- Create a wrapper for context.
- Use a more abstract context name - `WalletContext`
- Small improvements
Comment on lines +52 to +57
<Text as="b">
{!btcAccount || btcAccount?.balance.isZero()
? "0.00"
: formatSatoshiAmount(btcAccount.balance.toString())}
</Text>
<Text>{BITCOIN.symbol}</Text>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think would be great if we could create a reusable component where we just pass value and currency and all this stuff will be handled in a component. Otherwise, we always duplicate logic when displaying the amount. Ofc we can address it in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. Let's do it in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix it in #56.


export default function Navbar() {
return (
<Box p={4} display="flex" justifyContent="end">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging, we can use Flex component from Chakra <Flex p={4} justify="end">.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the next PR I use here HStack. I'm not quite sure which is better. But let's move the discussion there.

https://github.com/thesis/acre/pull/39/files#diff-1be1f6c0a32d0f6e752f271df1c943de18e74dc12767dc65676d0a36b6c2233aR9-R20

Copy link
Contributor

@r-czajkowski r-czajkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@r-czajkowski r-czajkowski merged commit 48965f3 into main Nov 28, 2023
9 checks passed
@r-czajkowski r-czajkowski deleted the connect-wallet branch November 28, 2023 14:50
@nkuba nkuba mentioned this pull request Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants